﻿using System;
using System.Data;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.SessionState;
using System.Collections;
using System.Web.UI.WebControls;
using DreamBuilder.DictionaryAccess;



namespace DreamBuilder.UI.UserControls
{
    public class ListBoundField :  System.Web.UI.WebControls.BoundField
    {
        bool htmlEncode = true;
        public ListBoundField() { }

        protected override bool SupportsHtmlEncode
　      {
　　　      get
　　　      {
                 return htmlEncode;
　　　      }
　      }
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState,int rowIndex)
　      {
　        if (this.HtmlEncode && cellType == DataControlCellType.Header)
　        {
　　         htmlEncode = false;
　　         base.InitializeCell(cell, cellType, rowState, rowIndex);
　　         htmlEncode = true;
　        }
　        else
　　         base.InitializeCell(cell, cellType, rowState, rowIndex);
　      }

        public ListBoundField(CVoucherListItemInfo voucherListItemInfo, SortData sortData)
        {
            FieldDicInfo fieldDicInfo = DictionaryAccessFacade.GetFieldDicInfo(voucherListItemInfo.TableCode, voucherListItemInfo.FieldCode);
            string sFormatString = ControlCommon.GetDataFormatType(fieldDicInfo);
            if (!string.IsNullOrEmpty(sFormatString))
            {
                this.DataFormatString = sFormatString;
            }
            ListHelper.SetGridViewColumnHeaderText(voucherListItemInfo, this, sortData);
            ListHelper.SetGridViewColumnStyle(voucherListItemInfo, this);
            this.DataField = voucherListItemInfo.TableCode + "__" + voucherListItemInfo.FieldCode;
        }
    }
}
